package D04;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class JunitFunctionTest {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, InvocationTargetException {
        //模拟Junit执行所有单元测试方法：
//1.获取测试类Class对象
        Class<CatJunitTest> testClass = CatJunitTest.class;
        //1.获取测试类Class对象的所有测试方法Method对象
        Method[] methods = testClass.getDeclaredMethods();
        //3.判断方法上是否有@MyTest注解
        for (Method method : methods) {
            if (method.isAnnotationPresent(MyTest.class)){
                method.invoke(testClass.newInstance());
            }
        }
    }
}

